#include "test_structure_mot.hpp"

void test_created_chained_word()
{
  chained_word c_w;
  bool ok=true;
  string c("");
  created_chained_word(c_w);

  if(c_w != NULL)
    ok=false;

  if(ok)
    cout << "TEST : created_chained_word ------------> OK" << endl;
  else
    cout << "TEST : created_chained_word ------------> NOK" << endl;

  cout << "Saisir une lettre" << endl;
  cin >> c;
}

void test_structure()
{
  bool ok=true;
  string tab_ref[100];
  string word="";
  chained_word c_w=NULL;
  list_word *l;

  for(int i=0;i<100;++i)
    {
      for(int m=0;m<5;++m)
	word+=(char)(41+rand()%136);
      tab_ref[i]=word;
      add_word(c_w,word,i);
    }

  for(int i=0;i<100;++i)
    {
      l=c_w;
      if(l->cpt!=i)
	ok=false;
      if(l->word!=tab_ref[i])
	ok=false;
      delete_word(c_w);
    }

  if(ok)
    cout << "TEST : structure -----------------------> OK" << endl;
  else
    cout << "TEST : structure -----------------------> NOK" << endl;

  cout << "Saisir une lettre" << endl;
  cin >> word;
}

int main()
{
  srand(time(NULL));

  test_created_chained_word();
  test_structure();

  return 0;
}
